<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Lap extends CI_Controller {

	public function __construct() {
		parent::__construct();
	}

	public function index(){
		if ($this->session->userdata('isLoggedIn')){
            $menu['isLoggedIn'] = true;
        }else {
        	redirect('site');
        }
		$this->load->model('kategori','',true);
		$this->load->model('laporan','',true);
		$data['laporan'] = $this->laporan->view();
		$menu['kategori'] = $this->kategori->get_all();
		$this->load->view('header');
		$this->load->view('menu',$menu);
		$this->load->view('laporan',$data);
		$this->load->view('footer');
	}

	public function month(){
		if ($this->session->userdata('isLoggedIn')){
            $menu['isLoggedIn'] = true;
        }else {
        	redirect('site');
        }
        $bln = $this->input->post('bulan');
        $thn = $this->input->post('tahun');
        $tanggal = "$thn-$bln-01";

		$this->load->model('kategori','',true);
		$this->load->model('laporan','',true);
		$data['laporan'] = $this->laporan->month($tanggal);
		$data['bln'] = $bln;
		$data['thn'] = $thn;
		$menu['kategori'] = $this->kategori->get_all();
		$this->load->view('header');
		$this->load->view('menu',$menu);
		$this->load->view('laporan',$data);
		$this->load->view('footer');
	}
	
}